home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / window2.zip / VLIB.A < prev    next >
Text File  |  1993-01-04  |  12KB  |  655 lines

  1.  
  2. ;    module:        vlib
  3. ;    programmer:    Ray L. McVay
  4. ;    started:    10 Oct 82
  5. ;    version:    2.01, 3 Aug 84
  6. ;    version:    2.1,  13 Jun 86    Larry A. Thiel
  7. ;
  8. ;    A library of c bios video functions originally written to
  9. ;    replace the int10() function of small-c:PC.
  10.  
  11. ;    history:
  12. ;    1.0    small-c:PC version
  13. ;    2.0    ported to DeSmet c
  14. ;    2.1    added get_page_, get_curtyp_, kbd_ci_, and kbd_csts
  15.  
  16. ;        Calling convention for DeSmet is to push parameters
  17. ;        rightmost first then do an intrasegment call to the
  18. ;        function.
  19.  
  20. ;        Char's, int's and unsigned's are returned in AX.
  21. ;        Long's are returned in DX:AX.
  22.  
  23. ;        CS, DS, SS, SP and BP should be preserved.
  24.  
  25. CSEG
  26. VIDEO    EQU    16    ;BIOS video interrupt
  27.  
  28.  
  29. ;    get video mode
  30. ; int get_mode();
  31.  
  32.     PUBLIC    GET_MODE_
  33. GET_MODE_:
  34.     mov    ah,15
  35.     int    VIDEO
  36.     cbw
  37.     ret
  38.  
  39.  
  40. ;    get video page
  41. ; int get_page();
  42.  
  43.     PUBLIC    GET_PAGE_
  44. GET_PAGE_:
  45.     mov    ah,15
  46.     int    VIDEO
  47.     mov    al,bh
  48.     cbw
  49.     ret
  50.  
  51.  
  52. ;    set video mode
  53. ; void set_mode(mode)
  54. ; int    mode;
  55.  
  56.     PUBLIC    SET_MODE_
  57. SET_MODE_:
  58.     push    bp
  59.     mov    bp,sp
  60.     mov    al,[bp+4]
  61.     mov    ah,0
  62.     INT    VIDEO
  63.     pop    bp
  64.     RET
  65.  
  66.  
  67. ;    set cursor type        
  68. ; void set_curtyp(start,end)
  69. ; int    start,end;
  70. ; Note: if start > end then cursor is turned off.
  71.  
  72.     PUBLIC    SET_CURTYP_
  73. SET_CURTYP_:
  74.     push    bp
  75.     mov    bp,sp
  76.     mov    ch,[bp+4]    ; top line
  77.     mov    cl,[bp+6]    ; bottom line
  78.     mov    ah,1
  79.     INT    VIDEO
  80.     pop    bp
  81.     RET
  82.  
  83.  
  84. ;    read cursor type
  85. ; int get_curtyp(page)
  86. ; int    page;
  87. ; startline = get_curtyp(page) & 255;    /* also contains blink, etc. flags */
  88. ; endline = get_curtyp(page) >> 8;
  89.  
  90.     PUBLIC    GET_CURTYP_
  91. GET_CURTYP_:
  92.     push    bp
  93.     mov    bp,sp
  94.     mov    bh,[bp+4]    ;BH = page
  95.     MOV    AH,3
  96.     INT    VIDEO
  97.     MOV    AX,CX        ;return(256*row+column)
  98.     pop    bp
  99.     RET
  100.  
  101.  
  102. ;    gotoxy - set cursor position    
  103. ; void gotoxy(x, y, page)
  104. ; int    x,y,page;
  105.  
  106.     PUBLIC    GOTOXY_
  107. GOTOXY_:
  108.     push    bp
  109.     mov    bp,sp
  110.     mov    dl,[bp+4]    ; DL = x = column
  111.     mov    dh,[bp+6]    ; DH = y = row
  112.     mov    bh,[bp+8]    ; BH = page
  113.     mov    ah,2
  114.     INT    VIDEO
  115.     pop    bp
  116.     RET
  117.  
  118.  
  119. ;    read cursor position
  120. ; int getxy(page)
  121. ; int    page;
  122. ; xpos = getxy(page) & 255;
  123. ; ypos = getxy(page) >> 8;
  124.  
  125.     PUBLIC    GETXY_
  126. GETXY_:
  127.     push    bp
  128.     mov    bp,sp
  129.     mov    bh,[bp+4]    ;BH = page
  130.     MOV    AH,3
  131.     INT    VIDEO
  132.     MOV    AX,DX        ;return(256*row+column)
  133.     pop    bp
  134.     RET
  135.  
  136.  
  137. ;    get light pen position
  138. ; int gltpen(buff)
  139. ; int    buff[4];
  140. ; Note: Returns 0 if pen was not triggered, 1 if it was.
  141. ;    Stores XY values in integer array at buff.
  142.  
  143.     PUBLIC    GLTPEN_
  144. GLTPEN_:
  145.     push    bp
  146.     mov    bp,sp
  147.     MOV    AH,4
  148.     INT     VIDEO
  149.     OR    AH,AH        ;check status
  150.     JZ    DOSTAT        ;it was bad
  151.     mov    si,[bp+4]    ;get addres of buffer
  152.     MOV    [SI],BX        ;buff[0]=X for graphics
  153.     MOV    [SI]+2,CH    ;buff[1]=Y
  154.     MOV    [SI]+4,DL    ;buff[2]=X for text
  155.     MOV    [SI]+6,DH    ;buff[3]=Y for text
  156.     MOV    AH,1        ;return OK status
  157. DOSTAT:
  158.     MOV    AL,AH
  159.     CBW
  160.     pop    bp
  161.     RET
  162.  
  163.  
  164. ;    select active page    
  165. ; void setpage(page)
  166. ; int    page;
  167.  
  168.     PUBLIC    SETPAGE_
  169. SETPAGE_:
  170.     push    bp
  171.     mov    bp,sp
  172.     mov    al,[bp+4]    ;page
  173.     MOV    AH,5
  174.     INT    VIDEO
  175.     pop    bp
  176.     RET
  177.  
  178.  
  179. ;    scroll a window up    
  180. ; void scrlup(window,count,attrib)
  181. ; int window[4],count,attrib;
  182. ; Note: Window defines the upper-left and lower-right
  183. ;    character positions of an area of the text screen.
  184. ;    A count of 0 clears the window.
  185. ;    The attribute is used on the line(s) blanked.
  186.  
  187.     PUBLIC    SCRLUP_
  188. SCRLUP_:
  189.     push    bp
  190.     CALL    SCRL1
  191.     MOV    AH,6
  192.     INT    VIDEO
  193.     pop    bp
  194.     RET
  195.  
  196. SCRL1:    mov    bp,sp
  197.     mov    bx,[bp+6]    ;get base of window array
  198.     MOV    CL,[bx]        ;window[0] = U.L. X
  199.     MOV    CH,[bx]+2    ;window[1] = U.L. Y
  200.     MOV    DL,[bx]+4    ;window[2] = L.R. X
  201.     MOV    DH,[bx]+6    ;window[3] = L.R. Y
  202.     mov    al,[bp+8]    ;AL = count
  203.     mov    bh,[bp+10]    ;BH = attribute
  204.     RET
  205.  
  206.  
  207. ;    scroll a window down    
  208. ; void scrldn(window,count,attrib)
  209. ; int window[4],count,attrib;
  210.  
  211.     PUBLIC    SCRLDN_
  212. SCRLDN_:
  213.     push    bp
  214.     CALL    SCRL1
  215.     MOV    AH,7
  216.     INT    VIDEO
  217.     pop    bp
  218.     RET
  219.  
  220.  
  221. ;    read character & attribute under the cursor
  222. ; int vgetc(page)
  223. ; int    page;
  224.  
  225.     PUBLIC    VGETC_
  226. VGETC_:
  227.     push    bp
  228.     mov    bp,sp
  229.     MOV    BH,[bp+4]
  230.     MOV    AH,8
  231.     INT    VIDEO
  232.     pop    bp
  233.     RET
  234.  
  235.  
  236. ;    write character & attribute at cursor
  237. ; void vputca(chr,page,count)
  238. ; int    chr,page,count;
  239. ; Note: Chr contains attribute in hi byte.
  240. ;    Count is the number of times to write the character.
  241. ;    (Good for tops and bottoms of windows or boxes.)
  242.  
  243.     PUBLIC    VPUTCA_
  244. VPUTCA_:
  245.     push    bp
  246.     CALL    VPUT1
  247.     MOV    AH,9
  248.     INT    VIDEO
  249.     pop    bp
  250.     RET
  251.  
  252. VPUT1:    
  253.     mov    bp,sp
  254.     mov    AX,[bp+6]    ;attrib/char
  255.     mov    bh,[bp+8]    ;page
  256.     mov    CX,[bp+10]    ;count
  257.     MOV    BL,AH        ;attrib to BL
  258.     RET
  259.  
  260.  
  261. ;    vputc - write character only at cursor    
  262. ; void vputc(chr,page,count)
  263. ; int    chr,page,count;
  264. ; Note:    Same as vputca() except uses existing attributes.
  265.  
  266.     PUBLIC    VPUTC_
  267. VPUTC_:
  268.     push    bp
  269.     CALL    VPUT1
  270.     MOV    AH,10
  271.     INT    VIDEO
  272.     pop    bp
  273.     RET
  274.  
  275.  
  276. ;    set background or pallet or alpha border color        
  277. ; void pcolor(id,val)
  278. ; int    id,val;
  279. ; Note:    If id == 0 then val is background color.
  280. ;    If id == 1 and mode is graphics then val is pallet.
  281. ;    If id == 1 and mode is text then val is border.
  282.  
  283.     PUBLIC    PCOLOR_
  284. PCOLOR_:
  285.     push    bp
  286.     mov    bp,sp
  287.     mov    bh,[bp+4]    ;id
  288.     mov    bl,[bp+6]    ;val
  289.     MOV    AH,11
  290.     INT    VIDEO
  291.     pop    bp
  292.     RET
  293.  
  294.  
  295. ;    write a graphics dot    
  296. ; void plot(color,horz,vert)
  297. ; int    color,horz,vert;
  298.  
  299.     PUBLIC    PLOT_
  300. PLOT_:
  301.     push    bp
  302.     CALL    SETDOT
  303.     MOV    AH,12
  304.     INT    VIDEO
  305.     pop    bp
  306.     RET
  307.  
  308. SETDOT:
  309.     mov    bp,sp
  310.     mov    AX,[bp+6]    ;color
  311.     mov    CX,[bp+8]    ;horiz
  312.     mov    DX,[bp+10]    ;vert
  313.     RET
  314.  
  315.  
  316. ;    read a graphic dot color
  317. ; int get_dot(dummy,horz,vert)    
  318. ; int    dummy,horz,vert;
  319. ; Note: the dummy parameter is used so SETDOT can be shared.
  320.  
  321.     PUBLIC    GET_DOT_
  322. GET_DOT_:
  323.     push    bp
  324.     CALL    SETDOT        ; set up the registers
  325.     MOV    AH,13
  326.     INT    VIDEO
  327.     cbw
  328.     pop    bp
  329.     RET            ; AX = dot color
  330.  
  331.         dseg
  332. ;    Larry A. Thiel        06/13/86
  333. ;
  334. ;    translated keyboard routines for use with the modified window package
  335. ;    originally downloaded from the cware bbs.
  336. ;
  337. ;    While this code was largely lifted from PCIO.A for DeSmet v2.51 and
  338. ;    is only useful for DeSmet owners, the extended key translation has
  339. ;    been changed to provide a translations for all the most useful keys
  340. ;    without implications of function as there are in PCIO.A.
  341. ;    The translated output conforms to the standards set by the IBMKEYS.H
  342. ;    file distributed with:
  343. ;
  344. ;  The Greenleaf Functions - Copyright (C) 1983,84,85 Greenleaf Software Inc.
  345. ;
  346. ;    This was done so to allow users of Greenleaf (such as myself) to use
  347. ;    only one include file of extended key definitions. I would have used
  348. ;    the Greenleaf functions but then could not have shared the modified
  349. ;    window package.
  350.  
  351. F1    equ    80h
  352. F2    equ    81h
  353. F3    equ    82h
  354. F4    equ    83h
  355. F5    equ    84h
  356. F6    equ    85h
  357. F7    equ    86h
  358. F8    equ    87h
  359. F9    equ    88h
  360. F10    equ    89h
  361.  
  362. SF1    equ    90h
  363. SF2    equ    91h
  364. SF3    equ    92h
  365. SF4    equ    93h
  366. SF5    equ    94h
  367. SF6    equ    95h
  368. SF7    equ    96h
  369. SF8    equ    97h
  370. SF9    equ    98h
  371. SF10    equ    99h
  372.  
  373. CF1    equ    0A0h
  374. CF2    equ    0A1h
  375. CF3    equ    0A2h
  376. CF4    equ    0A3h
  377. CF5    equ    0A4h
  378. CF6    equ    0A5h
  379. CF7    equ    0A6h
  380. CF8    equ    0A7h
  381. CF9    equ    0A8h
  382. CF10    equ    0A9h
  383.  
  384. AF1    equ    0E0h
  385. AF2    equ    0E1h
  386. AF3    equ    0E2h
  387. AF4    equ    0E3h
  388. AF5    equ    0E4h
  389. AF6    equ    0E5h
  390. AF7    equ    0E6h
  391. AF8    equ    0E7h
  392. AF9    equ    0E8h
  393. AF10    equ    0E9h
  394.  
  395. HOME        equ    8Ah    ; HOME key
  396. CURLF        equ    8Bh    ; <-
  397. ENDKEY        equ    8Ch    ; END key
  398. CURUP        equ    8Dh    ; up arrow
  399. CURDN        equ    8Eh    ; down arrow
  400. PGUP        equ    9Ah    ; PgUp
  401. CURRT        equ    9Bh    ; ->
  402. PGDN        equ    9Ch    ; PgDn
  403. INSERT        equ    9Dh    ; Ins
  404. DELETE        equ    9Eh    ; Del
  405. CTRLHOME    equ    0AAh    ; Ctrl Home
  406. CTRLCURLF    equ    0ABh    ; Ctrl <-
  407. CTRLEND        equ    0ACh    ; Ctrl End
  408. CTRLPRTSC    equ    0AEh    ; Ctrl PrtSc
  409. CTRLPGUP    equ    0BAh    ; Ctrl PgUp
  410. CTRLCURRT    equ    0BBh    ; Ctrl ->
  411. CTRLPGDN    equ    0BCh    ; Ctrl PgDn
  412. REVTAB        equ    08Fh    ; Shift Tab
  413. ALTMINUS    equ    0BDh    ; Alt -
  414. ALTEQUAL    equ    0BEh    ; Alt =
  415.  
  416. ALT1    equ    0B1h
  417. ALT2    equ    0B2h
  418. ALT3    equ    0B3h
  419. ALT4    equ    0B4h
  420. ALT5    equ    0B5h
  421. ALT6    equ    0B6h
  422. ALT7    equ    0B7h
  423. ALT8    equ    0B8h
  424. ALT9    equ    0B9h
  425. ALT0    equ    0B0h
  426.  
  427. ALTA    equ    0C1h
  428. ALTB    equ    0C2h
  429. ALTC    equ    0C3h
  430. ALTD    equ    0C4h
  431. ALTE    equ    0C5h
  432. ALTF    equ    0C6h
  433. ALTG    equ    0C7h
  434. ALTH    equ    0C8h
  435. ALTI    equ    0C9h
  436. ALTJ    equ    0CAh
  437. ALTK    equ    0CBh
  438. ALTL    equ    0CCh
  439. ALTM    equ    0CDh
  440. ALTN    equ    0CEh
  441. ALTO    equ    0CFh
  442. ALTP    equ    0D0h
  443. ALTQ    equ    0D1h
  444. ALTR    equ    0D2h
  445. ALTS    equ    0D3h
  446. ALTT    equ    0D4h
  447. ALTU    equ    0D5h
  448. ALTV    equ    0D6h
  449. ALTW    equ    0D7h
  450. ALTX    equ    0D8h
  451. ALTY    equ    0D9h
  452. ALTZ    equ    0DAh
  453.  
  454. CTRLBREAK    equ    0    ; when break testing is off
  455. NULKEY        equ    003h
  456. BADKEY        equ    0FFh    ; invalid value
  457.  
  458. ;    table used to make extended key code translations
  459.  
  460. convert:
  461. ;        return value     extended scan code
  462. ;        ------------     ------------------
  463.     db    BADKEY        ;0
  464.     db    BADKEY        ;1
  465.     db    BADKEY        ;2
  466.     db    CTRLBREAK    ;3
  467.     db    BADKEY        ;4
  468.     db    BADKEY        ;5
  469.     db    BADKEY        ;6
  470.     db    BADKEY        ;7
  471.     db    BADKEY        ;8
  472.     db    BADKEY        ;9
  473.     db    BADKEY        ;10
  474.     db    BADKEY        ;11
  475.     db    BADKEY        ;12
  476.     db    BADKEY        ;13
  477.     db    BADKEY        ;14
  478.     db    REVTAB        ;15
  479.     db    ALTQ        ;16
  480.     db    ALTW        ;17
  481.     db    ALTE        ;18
  482.     db    ALTR        ;19
  483.     db    ALTT        ;20
  484.     db    ALTY        ;21
  485.     db    ALTU        ;22
  486.     db    ALTI        ;23
  487.     db    ALTO        ;24
  488.     db    ALTP        ;25
  489.     db    BADKEY        ;26
  490.     db    BADKEY        ;27
  491.     db    BADKEY        ;28
  492.     db    BADKEY        ;29
  493.     db    ALTA        ;30
  494.     db    ALTS        ;31
  495.     db    ALTD        ;32
  496.     db    ALTF        ;33
  497.     db    ALTG        ;34
  498.     db    ALTH        ;35
  499.     db    ALTJ        ;36
  500.     db    ALTK        ;37
  501.     db    ALTL        ;38
  502.     db    BADKEY        ;39
  503.     db    BADKEY        ;40
  504.     db    BADKEY        ;41
  505.     db    BADKEY        ;42
  506.     db    BADKEY        ;43
  507.     db    ALTZ        ;44
  508.     db    ALTX        ;45
  509.     db    ALTC        ;46
  510.     db    ALTV        ;47
  511.     db    ALTB        ;48
  512.     db    ALTN        ;49
  513.     db    ALTM        ;50
  514.     db    BADKEY        ;51
  515.     db    BADKEY        ;52
  516.     db    BADKEY        ;53
  517.     db    BADKEY        ;54
  518.     db    BADKEY        ;55
  519.     db    BADKEY        ;56
  520.     db    BADKEY        ;57
  521.     db    BADKEY        ;58
  522.     db    F1        ;59
  523.     db    F2        ;60
  524.     db    F3        ;61
  525.     db    F4        ;62
  526.     db    F5        ;63
  527.     db    F6        ;64
  528.     db    F7        ;65
  529.     db    F8        ;66
  530.     db    F9        ;67
  531.     db    F10        ;68
  532.     db    BADKEY        ;69
  533.     db    BADKEY        ;70
  534.     db    HOME        ;71
  535.     db    CURUP        ;72
  536.     db    PGUP        ;73
  537.     db    BADKEY        ;74
  538.     db    CURLF        ;75
  539.     db    BADKEY        ;76
  540.     db    CURRT        ;77
  541.     db    BADKEY        ;78
  542.     db    ENDKEY        ;79
  543.     db    CURDN        ;80
  544.     db    PGDN        ;81
  545.     db    INSERT        ;82
  546.     db    DELETE        ;83
  547.     db    SF1        ;84
  548.     db    SF2        ;85
  549.     db    SF3        ;86
  550.     db    SF4        ;87
  551.     db    SF5        ;88
  552.     db    SF6        ;89
  553.     db    SF7        ;90
  554.     db    SF8        ;91
  555.     db    SF9        ;92
  556.     db    SF10        ;93
  557.     db    CF1        ;94
  558.     db    CF2        ;95
  559.     db    CF3        ;96
  560.     db    CF4        ;97
  561.     db    CF5        ;98
  562.     db    CF6        ;99
  563.     db    CF7        ;100
  564.     db    CF8        ;101
  565.     db    CF9        ;102
  566.     db    CF10        ;103
  567.     db    AF1        ;104
  568.     db    AF2        ;105
  569.     db    AF3        ;106
  570.     db    AF4        ;107
  571.     db    AF5        ;108
  572.     db    AF6        ;109
  573.     db    AF7        ;110
  574.     db    AF8        ;111
  575.     db    AF9        ;112
  576.     db    AF10        ;113
  577.     db    CTRLPRTSC    ;114
  578.     db    CTRLCURLF    ;115
  579.     db    CTRLCURRT    ;116
  580.     db    CTRLEND        ;117
  581.     db    CTRLPGDN    ;118
  582.     db    CTRLHOME    ;119
  583.     db    ALT1        ;120
  584.     db    ALT2        ;121
  585.     db    ALT3        ;122
  586.     db    ALT4        ;123
  587.     db    ALT5        ;124
  588.     db    ALT6        ;125
  589.     db    ALT7        ;126
  590.     db    ALT8        ;127
  591.     db    ALT9        ;128
  592.     db    ALT0        ;129
  593.     db    ALTMINUS    ;130
  594.     db    ALTEQUAL    ;131
  595.     db    CTRLPGUP    ;132
  596. tbl_end:
  597.  
  598. ;    equates for bios interface.
  599.  
  600.  
  601. ;    the interrupt and codes for the keyboard interface.
  602.  
  603. keyboard    equ    16h        ;interrupt 16 to deal with keyboard
  604.  
  605. cicode        equ    0        ;code for reading a character
  606. cstscode    equ    1        ;code for keyboard status
  607.  
  608.         cseg
  609.  
  610. ;    KBD_CI_            keyboard input. function and soft keys are
  611. ;                translated. see equates for values.
  612.  
  613. ;                Usage:    character = kbd_ci();
  614.  
  615.         public    kbd_ci_
  616. kbd_ci_:                ;return the next character
  617.                     ; translate if necessary
  618.         push    bp
  619.         mov    ah,cicode    ;ask for a keyboard character
  620.         int    keyboard
  621.         cmp    al,0
  622.         jne    not_special
  623.         mov    bx, offset convert    ; convert special key
  624.         mov    al, ah
  625.         mov    ah, 0
  626.         add    bx, ax            ;offset by extended code
  627.         cmp    bx, offset tbl_end    ;verify in table
  628.         jle    translate
  629.         mov    al, BADKEY        ;indicate if not
  630.         jmp    not_special
  631. translate:    mov    al, [bx]        ;get translation
  632. not_special:    mov    ah,0
  633.         pop    bp
  634.         ret
  635.  
  636.  
  637. ;    KBD_CSTS_        return character if any available. otherwise
  638. ;                return zero.
  639.  
  640. ;                Usage:    character = kbd_csts();
  641.  
  642.         public    kbd_csts_
  643. kbd_csts_:                ;return coded character if any available
  644.         push    bp
  645.         mov    ah,cstscode
  646.         int    keyboard
  647.         mov    ax,0
  648.         jz    csts_over
  649.         call    kbd_ci_        ;get the coded character
  650. csts_over:    pop    bp
  651.         ret
  652.  
  653.  
  654.     END
  655.